package lovoStudy_9_6.game;

/**
 * Created with Intellij IDEA
 * Description:
 *
 * @ return:
 * @ author:zxl
 */
public class Judge {
    /**
     * 判断玩家和电脑的出拳情况
     * */
    private Player player = new Player("张飞");
    private Computer computer = new Computer();
    public void check(){
        //积分标记变量
        int playerIndex = 0;
        int computerIndex = 0;

       for (int i = 0; i< 5 ; i++){
            System.out.println("猜拳游戏开始! 请输入 1-石头 2-剪刀 3-布");
            int playerNum = player.input();
            int computerNum = computer.input();
            if (playerNum == computerNum){
                System.out.println("平局");
                continue;
            }
            if ((playerNum == 1 && computerNum == 2)||(playerNum == 2 && computerNum == 3)||((playerNum == 3 && computerNum == 1))){
                System.out.println("你赢下一局!");
                player.setScore(++playerIndex);
                System.out.println(computerNum);
                continue;
            }else {
                System.out.println("这局你输了!");
                computer.setScore(++computerIndex);
                System.out.println(computerNum);
                continue;
            }

        }
       if (player.getScore() > computer.getScore()){
           System.out.println("你的得分是" + player.getScore() + "你赢啦!" + player.getName());
       }else {
           System.out.println("你的得分是" + player.getScore() + "你输了!" + player.getName());
       }




    }
}
